#include "RoamArea.h"

using namespace Geometry;

RoamArea::RoamArea( Geometry::PolygonVolume* area,int pause,int variance,bool spawnhere)
{
	_polygon = area;
	_pauseTime = pause;
	_pauseVariance = variance;
	_spawnRandom = spawnhere;
}

RoamArea::~RoamArea()
{
	if( _polygon == NULL )
	{
		delete _polygon;
	}
}

vertex RoamArea::GetRandomPoint()
{
	vertex v;

	if( _polygon != NULL )
	{
		v = _polygon->GetRandomPoint();
	}

	return v;
}

int RoamArea::GetPauseTime()
{
	int time = _pauseTime;

	if( _pauseVariance > 0 )
	{
		time = Geometry::RandomIntRange(_pauseTime-_pauseVariance,_pauseTime+_pauseVariance);
		if( time < 0 ) time = 0;
	}

	return time;
}

bool RoamArea::IsValid()
{
	if( _polygon != NULL )
	{
		if( _polygon->GetVertexCount() > 3 )
		{
			return true;
		}
	}
	return false;
}

/*
VERTEX RoamArea::GetRandomPoint()
{
	VERTEX v;

	return v;
}
*/